/**
 * 物料大类下拉列表
 * 参数   交易码：trancode=GoodsType
 * @author liuguangshuai@gmail.com
 */

package org.ccams.tran;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.ccams.domain.TGoodskind;

public class TranGoodsKind extends AbstractJsonTran {

	@SuppressWarnings("unchecked")	
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		ArrayList<TGoodskind> al = new ArrayList<TGoodskind>();
		List<TGoodskind> list = getCcamsService().getTgoodskindDao().getAll();
		for(TGoodskind t : list){
			TGoodskind tp = new TGoodskind();
			tp.setIdtGoodskind(t.getIdtGoodskind());
			tp.setKindname(t.getKindname());
			al.add(tp);
		}
		JSONArray JsonArray = JSONArray.fromObject(al); //得到JSON数组 
        jsonMap.put("root", JsonArray);
        json.putAll(jsonMap);
	}
}